<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="javax.naming.*" %>

<%
	request.setCharacterEncoding("utf-8");

	String no=request.getParameter("no");
	String state=request.getParameter("state");

	boolean check = false;

	Connection conn=null;
	//Context ctx=null;
	Statement stmt=null;
	
	try{
		//Hashtable ht=new Hashtable();
		//ht.put (Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
		//ht.put (Context.PROVIDER_URL, "t3://192.168.56.101:7011");
		
		Context initCtx = new InitialContext();
		Context envCtx = (Context)initCtx.lookup("java:/conf/env");
		DataSource ds=(DataSource)envCtx.lookup("test");	// JNDI
		conn=ds.getConnection();

		stmt=conn.createStatement(); // SQL 문장을생성
		stmt.executeQuery("INSERT INTO TEST VALUES('" + no + "', '"+ state + "')"); // SQL 문장 실행
		check = true;	
	}catch(Exception e){
	 	check = false;	
   		System.out.println("인서트 에러");
	}finally{
		if(stmt != null)	stmt.close();		// 반환
		if(conn != null)	conn.close(); // 반환
	}
%>

<html>
	<head><title>insert reselt</title></head>
	<body>
		<% if(check==true) { %>	
			<a href="./insertCheck.jsp"> Success Check !!</a>
		<% } else { %>	
			<a href="./insertForm.jsp"> Error !!</a>	
   		<% } %>
	</body>
</html>
